<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

<script src="js/communication/ComPort.js" type="text/javascript"></script>
<script src="js/communication/SCISCommand.js" type="text/javascript"></script>
<script src="js/ElectronicScale.js" type="text/javascript"></script>

<script type="text/javascript">
    var electronicScale;
    window.onload = function (ev) {
        electronicScale = new ElectronicScale();
        electronicScale.openDevice();
        // electronicScale.bindWeightInfoCallback(function (weightInfo) {
        //     console.log(weightInfo.grossWeight);
        //     console.log(weightInfo.tareWeight);
        //     console.log(weightInfo.netWeight);
        // });
    }
    window.onunload = function (ev) {
        electronicScale.closeDevice();
        alert("onunload");
    }
    function sendDataGross() {
        electronicScale.queryGrossWeight(function (response) {
            var data = response.content;
            console.log("sendDataGross重量信息："+data);
        });
    }
    function sendDataNet() {
        //查询重量信息
        electronicScale.queryNetWeight(function (response) {
            var data = response.content;
            console.log("数据:"+data);
            var integer = data.match(/^[0-9]+([.]{1}[0-9]+){0,1}$/gi);
            var unit = data.match(/^[A-Za-z]+/gi);
            console.log("重量："+integer);
            console.log("单位："+unit);
            // setTimeout("sendDataGross()",100);
        });
        
    }
</script>

<body>
    <input type="button" onclick="sendDataNet()" value="载车检斤">
</body>
</html>